package com.hl.sfzy.controller;

import com.hl.sfzy.entity.Consultant;
import com.hl.sfzy.service.ConsultantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/consultants")
public class ConsultantController {
    @Autowired
    private ConsultantService consultantService;

    @GetMapping("/search")
    public ResponseEntity<Map<String, Object>> getConsultants(
            @RequestParam(required = false) String teacherGradeName,
            @RequestParam(required = false) String fieldName) {
        List<Consultant> consultants = consultantService.getConsultants(teacherGradeName, fieldName);

        Map<String, Object> response = new HashMap<>();
        response.put("consultants", consultants);
        return ResponseEntity.ok(response);
    }
}
